#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main() {
    vector<int> fab(10001);
    fab[0] = 1;
    fab[1] = 1;
    for (int i = 2; i <= 10000; ++i)
    {
        fab[i] = fab[i - 1] + fab[i - 2];
        fab[i] %= 10000;
    }

    int n;
    while (cin >> n)
    {
        while (n--)
        {
            int num;
            cin >> num;
            printf("%04d", fab[num]);
        }
        cout << endl;
    }
    return 0;
}